home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / COUNTWRD.AML < prev    next >
Text File  |  1996-07-17  |  1KB  |  42 lines

  1. //--------------------------------------------------------------------
  2. // COUNTWRD.AML
  3. // Count Words, (C) 1993-1996 by nuText Systems
  4. //
  5. // This macro counts the number of words in the current file and
  6. // displays the result. The count is limited to a marked block if it
  7. // exists.
  8. //
  9. // Words are defined to be contiguous sequences of alphabetic characters
  10. // of mixed case, and the underline (_) character.
  11. //
  12. // Usage:
  13. //
  14. // Select this macro from the Macro List (on the Macro menu), or run it
  15. // from the macro picklist <shift f12>.
  16. //--------------------------------------------------------------------
  17.  
  18. // compile time macros and function definitions
  19. include  bootpath "define.aml"
  20.  
  21. // test for edit windows
  22. if not wintype? "edit" then
  23.   msgbox "Edit windows only!"
  24.   return
  25. end
  26.  
  27. // test if a marked block exists in the current file
  28. block_count = mark? and getmarkbuf == getcurrbuf
  29.  
  30. // display message
  31. say "Counting words" + (if? block_count " in block") + "..."
  32.  
  33. // count words using regular expression searching
  34. count = find "[a-zA-Z_]#"  "axg" + (if? block_count 'b')
  35.  
  36. // clear the title bar
  37. display
  38.  
  39. // display the word count
  40. shortbox  (if? count (thousands count) "No") + " words found" +
  41.           (if? block_count " in the block")
  42.